import request from '@/utils/request'

// 添加评价
export function addReview(data: any) {
  return request({
    url: '/user/reviews',
    method: 'post',
    data
  })
}

// 获取用户评价列表
export function getUserReviews(params?: any) {
  return request({
    url: '/user/reviews',
    method: 'get',
    params
  })
}

// 删除评价
export function deleteReview(id: number) {
  return request({
    url: `/user/reviews/${id}`,
    method: 'delete'
  })
}

// 检查订单是否已评价
export function checkReview(orderNo: string, productId: number) {
  return request({
    url: '/user/reviews/check',
    method: 'get',
    params: { orderNo, productId }
  })
}

// 获取订单评价
export function getOrderReview(orderNo: string, productId: number) {
  return request({
    url: '/user/reviews/order',
    method: 'get',
    params: { orderNo, productId }
  })
}

// 获取商品评价列表
export function getProductReviews(productId: number, params?: any) {
  return request({
    url: `/products/${productId}/reviews`,
    method: 'get',
    params
  })
}
